class Solution {
    public static void main(String[] args) {
        System.out.println(new Solution().singleNumber(new int[]{3, 4, 3, 3}));
    }

    public int singleNumber(int[] nums) {
        int[] arr = new int[32];
        for (int i = nums.length - 1; i >= 0; i--) {
            int temp = 1;
            for (int j = 31; j >= 0; j--) {
                arr[j] += (nums[i] & temp) == 0 ? 0 : 1;
                temp <<= 1;
            }
        }
        int res = 0;
        for (int i = 0; i < 32; i++) {
            if (arr[i] % 3 != 0) {
                res += 1 << (31 - i);
            }
        }
        return res;
    }
}